{extend name="user:base" /}
{block name="title"}我发布的文章-米醋儿{/block}
{block name="main"}
<style>
    .blockquote-footer::before {
        content: none;
    }
</style>
<!-- begin::main content -->
<main class="main-content">

    <div class="page-header d-md-flex justify-content-between align-items-center">
        <h4>我的文章</h4>
    </div>


    {foreach $list as $k=> $v}
    <div class="card p-3">


        <p>
            <a target="_blank" href="{:url('Article/read',['id'=>$v.id])}">
                {$v.title}
            </a>

            {if $v.status == 2}
            <span class="badge badge-pill badge-warning">草稿</span>
            {/if}
        </p>

        <footer class="blockquote-footer">
            <figure class="avatar avatar-sm">
                {if $v.user.headimgurl}
                <img src="{$v.user.headimgurl}" alt="" class="rounded-circle">
                {else/}
                <img src="https://www.layui.com/admin/std/dist/layuiadmin/style/res/template/portrait.png" alt=""
                     class="rounded-circle">
                {/if}
            </figure>
            <small class="text-muted">
                发布于 <cite title="Source Title">{$v.add_time}</cite>
            </small>
        </footer>
        <br>


        <hr>
        <div class="btngroup">
            <button onclick="view({$v.id})" type="button"
                    data-toggle="tooltip" data-placement="top" title="" data-original-title="预览"
                    class="btn btn-outline-success btn-uppercase btn-floating">
                预
            </button>
            <button onclick="edit({$v.id})" type="button"
                    class="btn btn-outline-success btn-floating"
                    data-toggle="tooltip" data-placement="top" title="" data-original-title="编辑"
                    title="编辑">
                <i class="ti-check-box"></i>
            </button>
            <button type="button" class="btn btn-outline-danger btn-floating" title="删除"
                    data-toggle="tooltip" data-placement="top" title="" data-original-title="删除"
                    onclick="del({$v.id})">
                <i class="ti-trash"></i>
            </button>
        </div>

    </div>
    {/foreach}
    {$list|raw}
</main>

<script>
    //Demo

    function del(id) {
        var url = "{:url('delete')}";
        layer.confirm('确定要删除此记录么？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.post(url, {id: id}, function (e) {
                if (e.code == 200) {
                    success(e.msg);
                    setTimeout("location.reload()", 1000)
                } else {
                    error(e.msg)
                }
            })
        }, function () {
            layer.msg('已取消');
        });

    }
    function edit(id) {
        var url = "{:url('Uarticle/edit')}/id/" + id;
        url = url.replace(".html", "");
        location.href = url
    }

    //预览
    function view(id) {
        var url = "{:request()->domain()}/new/" + id;
        url = url.replace(".html", "");
        location.href = url
    }


</script>

{/block}
